// OSCClass simple send test Arduino sketch
// OSCClass version 1.0.1 (Arduino ver0014)
// Copyright (c) recotana(http://recotana.com).  All right reserved.


// osc send message (1000ms interval)

#include "Ethernet.h"
#include "OSCClass.h"

  byte serverMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
  byte serverIp[]  = { 192, 168, 0, 99 };
  int  serverPort  = 10000;
  
//  byte gateway[]   = { 192, 168, 0, 1 };
//  byte subnet[]    = { 255, 255, 255, 0 };


  byte destIp[]  = { 192, 168, 0, 5};
  int  destPort = 10000;
  
  char *topAddress="/ard";
  char *subAddress[1]={ "/test1"  };
  
  OSCMessage recMes;
  OSCMessage sendMes;
  
  OSCClass osc(&recMes);

void setup() {
  
     Ethernet.begin(serverMac ,serverIp);
 //    Ethernet.begin(serverMac ,serverIp ,gateway ,subnet);
    
     //setting osc recieve server
     osc.begin(serverPort);
   
   
     //for message logging
     Serial.begin(19200);
     
     //osc message buffer clear
     osc.flush();
     
     
      sendMes.setIp( destIp );
      sendMes.setPort( destPort );
      sendMes.setTopAddress(topAddress);
      sendMes.setSubAddress(subAddress[0]);
}

void loop() {
  
 
   long    v1 = 0;    //long or unsigned long only (not int)
   double  v2 = 0.0;  //double only ( not float) 
   
   
   while(1){
     
      if( v1++ >10000 ) v1=0;
      if( (v2+=1.1) >50 ) v2=0;   
 
      sendMes.setArgs("if" ,&v1 ,&v2);
  
      osc.sendOsc( &sendMes );
  


      delay(1000);
   }
}
 
